<template >
    <!-- 折叠面板 -->
    <el-collapse-item :title="'title:'+date.id" :name="'zhedie'+String(date.id)" v-if="!isDelete">  
        <!-- <div>{{date.message1}}</div> -->
        <!-- 
                "id":1459922348237443074,
                "qid":555,"aid":666,
                "content":"测试数据",
                "deleted":false,
                "rank":10,
                "status":0,
                "submittime":"2021-11-14T16:33:06.000+00:00"}
             -->
        <el-descriptions :column="4" border >
            <el-descriptions-item label="id" :span="4">{{date.id}}</el-descriptions-item>
            <el-descriptions-item label="qid" :span="2">{{date.qid}}</el-descriptions-item>
            <el-descriptions-item label="aid" :span="2">{{date.aid}}</el-descriptions-item>
            <el-descriptions-item label="积分数" :span="2">{{date.rank}}</el-descriptions-item>
            <el-descriptions-item label="状态" :span="2">{{statusTostring}}</el-descriptions-item>
            <el-descriptions-item label="提交时间" :span="2" >{{date.submittime}}</el-descriptions-item>
            <!-- <el-descriptions-item label="备注">
              <el-tag size="small">学校</el-tag>
            </el-descriptions-item> -->
            <el-descriptions-item label="操作" :span="2" v-if="isAnswerer">
                <el-button v-if="status!=0" type="danger" plain @click="delstd(date.id)">删除</el-button>
                <el-button v-if="status==0" type="success" plain @click="receiveById(date.id)">接收</el-button>
              </el-descriptions-item>
            <el-descriptions-item label="message1" :span="4">{{date.content}}</el-descriptions-item>

        </el-descriptions>
      </el-collapse-item>

</template>
<script>
export default {
    name:"submitTableDate",
    data() {
        return {
            name:this.date.id,
            isDelete:false,
            status:this.date.status,
        }
    },
    mounted() {
        // console.log("date",this.date)
    },
    computed:{
        statusTostring(){
            if(this.status==0){
                return "未提交"
            }
            
            if(this.status==1){
                return "已提交"
            }
            
            if(this.status==2){
                return "已过期"
            }

            return "status error :" + this.status
        },
        isAnswerer(){
            if(this.$cookies.get("authority")=="Answerer" ||
             this.$cookies.get("authority"=="answerer")){
                 return true
             }
             return false
        }
    },
    props:['date'],
    methods: {
        delstd (row) {
		if(confirm('确定要删除吗')==true){
			// this.handleDelete(row)
            this.deleteByid(row)
            console.log("删除请求：id="+row)
		}
	},
    receiveById(id){
        this.$axios.get(this.MYURL + `/submitTable/dealSubmitTable/${id}`)
          // http://localhost:8001/miaosha/selectAll 
          .then(res => {
            if(res){
                console.log("成功接收预约:"+id)
                // this.isDelete="true"
                this.status=1
            }

          }
          )
          .catch(function (error) { alert("请求失败" + error) })
    },
    deleteByid(id){
        this.$axios.get(this.MYURL + `/submitTable/delete/${id}`)
          // http://localhost:8001/miaosha/selectAll 
          .then(res => {
            if(res){
                console.log("删除成功："+id)
                this.isDelete="true"
            }

          }
          )
          .catch(function (error) { alert("请求失败" + error) })
      
    }
    },
}
</script>
<style scoped>



</style>